<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/2/28
 * Time: 23:25
 */

namespace app\common\model;


class BoolStatus
{
    /**
     * 开 状态
     */
    const OPEN = 1;

    /**
     * 关 状态
     */
    const CLOSE = 0;

    /**
     * 获取所有开关标签
     * @return array
     */
    public static function getLables()
    {
        return [
            self::OPEN  => '有效',
            self::CLOSE => '无效',
        ];
    }

    /**
     * 获取有颜色的所有开关标签
     * @return array
     */
    public static function getColorLables()
    {
        return [
            self::OPEN  => '<span style="color:#0f0;">有效</span>',
            self::CLOSE => '<span style="color:#f00;">无效</span>',
        ];
    }

    /**
     * 获取某一状态名称
     * @param int $state 状态值
     * @return mixed|string
     */
    public static function getLabelName($state)
    {
        $lables = self::getColorLables();
        return isset($lables[$state]) ? $lables[$state] : '未定义状态';
    }

}